package com.corewillsoft.fireflies.gameobjects.obstacles.trajectories;

import java.util.List;

import com.corewillsoft.fireflies.gameobjects.obstacles.ITrajectory;

/**
 * Abstract class describing methods required for calculation of trajectory of particular object
 */
public abstract class Trajectory {

	/**
	 * Enumeration of possible types of trajectory
	 */
	public static enum TrajectoryType {
		POINT, CIRCULAR, RECTANGULAR, POLYLINE
	}

	/**
	 * List of trajectory parameters; for each particular trajectory there are different parameters
	 */
	protected List<Float> parameters;

	/**
	 * Recalculated new X-component of speed of the object; this value should be calculated by implementation of {@link Trajectory#calculateSpeed(float, float, float)} method
	 */
	protected float speedX = 0;

	/**
	 * Recalculated new Y-component of speed of the object; this value should be calculated by implementation of {@link Trajectory#calculateSpeed(float, float, float)} method
	 */
	protected float speedY = 0;

	/**
	 * Delegate, method of which should be called by Trajectory instance,
	 * when some parameter of obstacle passed to Trajectory instance is changed by it; the method
	 * of this delegate should set correctly value of changed parameter in the obstacle's parameters map
	 */
	protected ITrajectory obstacle;

	/**
	 * Calculates X- and Y- components of speed of object bound to this trajectory;
	 * to get calculated speed components, one should call {@link com.corewillsoft.fireflies.gameobjects.obstacles.trajectories.Trajectory#getSpeedX()} and {@link com.corewillsoft.fireflies.gameobjects.obstacles.trajectories.Trajectory#getSpeedY()}
	 * after calling of this method
	 * @param x - current X-coordinate of the moving object
	 * @param y - current Y-coordinate of the moving object
	 * @param maxSpeed - maximal absolute value of speed of the moving object
	 */
	public abstract void calculateSpeed(float x, float y, float maxSpeed);

	public Trajectory(List<Float> parameters) {
		setParameters(parameters);
	}

	protected void setParameters(List<Float> parameters) {
		this.parameters = parameters;
	}

	public float getSpeedX() {
		return speedX;
	}

	public float getSpeedY() {
		return speedY;
	}

	public void setParametersChangedListener(ITrajectory obstacle) {
		this.obstacle = obstacle;
	}
}
